%{
#include "linreg.h"
%}


/**
* Linear Regression
*/

%rename (LinearModel) linearmodel;
%rename (LrReport) lrreport;

struct linearmodel
{
    ap::real_1d_array w;
};
struct lrreport
{
    ap::real_2d_array c;
    double rmserror;
    double avgerror;
    double avgrelerror;
    double cvrmserror;
    double cvavgerror;
    double cvavgrelerror;
    int ncvdefects;
    ap::integer_1d_array cvdefects;
};


void lrbuild(const ap::real_2d_array& xy,
     int npoints,
     int nvars,
     int& info,
     linearmodel& lm,
     lrreport& ar);

void lrbuilds(const ap::real_2d_array& xy,
     const ap::real_1d_array& s,
     int npoints,
     int nvars,
     int& info,
     linearmodel& lm,
     lrreport& ar);
     
void lrbuildzs(const ap::real_2d_array& xy,
     const ap::real_1d_array& s,
     int npoints,
     int nvars,
     int& info,
     linearmodel& lm,
     lrreport& ar);

void lrbuildz(const ap::real_2d_array& xy,
     int npoints,
     int nvars,
     int& info,
     linearmodel& lm,
     lrreport& ar);
     
void lrunpack(const linearmodel& lm, ap::real_1d_array& v, int& nvars);
void lrpack(const ap::real_1d_array& v, int nvars, linearmodel& lm);
double lrprocess(const linearmodel& lm, const ap::real_1d_array& x);
